import React from 'react';
import CommonList from '../../../components/CommonLists/list';
import { Button } from 'antd';
import { MODULE_TYPE } from '../../../utils/constant';

const POP_WIDTH = {
  _APP: 500, //渠道
  _EVENT: 500, //事件
  _RISK_TYPE: 500, //风险类型
  _FIELD: 600, //字段
  _FEATURE: 1000, //指标
  _STRATEGY: 1200, //策略
  _STRATEGY_COMPONENT: 1200, //策略
  _NAMELIST: 1000, //名单
  _MODEL: 1000, //模型
  _THIRD_NAMELIST: 1000, //映射管理
  __CUSTOM_PARAMS: 1200, // 自定义出参
};
const TITLE = {
  _APP: '渠道', //渠道
  _EVENT: '事件', //事件
  _RISK_TYPE: '风险类型', //风险类型
  _FIELD: '字段', //字段
  _FEATURE: '指标', //指标
  _STRATEGY: '策略', //策略
  _NAMELIST: '名单', //名单
  _MODEL: '模型', //模型
  _THIRD_NAMELIST: '映射管理', //映射管理
  _ACTION: '函数',
  _STRATEGY_COMPONENT: '策略组件', //策略组件
  _CUSTOM_PARAMS: '自定义参数', //自定义参数
  _MAP: '映射管理', // 映射管理
  _INDEX_DATASOURCE: '指标数据源'
};

class AuditList extends CommonList {
  constructor(props) {
    super(props);
    this.api = 'audit';
    this.operatorWidth = 120;
    this.tableParams = {
      scroll: {
        x: 1400
      },
    }
    this.state = {
      events: [],
    };

    this.detailButton = (record) => {
      let currentKey = '';
      for (let key in MODULE_TYPE) {
        if (MODULE_TYPE[key] === record.module_type) {
          currentKey = key;
        }
      }
      const width = POP_WIDTH[currentKey];
      return (
        <Button
          size='small'
          type='link'
          onClick={() => this.props.showDetail(record, `${TITLE[currentKey]}数据详情`, width)}
        >
          详情
        </Button>
      );
    };
    this.labDetailButton = record => {
      return (
        <Button
          size='small'
          type='link'
          onClick={() => this.props.labDetail(record)}
          disabled={record.oper_type !== 10}
        >
          试验详情
        </Button>
      );
    };
    this.btnGroup = [this.detailButton, this.labDetailButton];
  }
  componentDidMount() {}
}

export default AuditList;
